﻿using FunArts.EasyDevOps.Shared.Models.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FunArts.EasyDevOps.Shared.Models.SshClient.Command
{
    /// <summary>
    /// 启动Java项目命令
    /// </summary>
    public class StartJavaProjectCommand : ILinuxCommand
    {
        /// <summary>
        /// JAR文件路径
        /// </summary>
        public string JarPath { get; set; } 
        /// <summary>
        /// 启动参数
        /// </summary>
        public string Arguments { get; set; } 
        /// <summary>
        /// 是否在后台运行
        /// </summary>
        public bool RunInBackground { get; set; } 


        public string BuildCommand(SystemVersionTypeEnum systemVersionType)
        {
            string command = $"java -Xms256m -Xmx512m -XX:PermSize=256m -XX:MaxPermSize=512m -jar {JarPath} {Arguments} > /dev/null 2>&1";
            return RunInBackground ? $"nohup {command} &" : command;
        }
    }
}
